package io.renren.modules.appManagement.controller;

import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.appManagement.entity.AppFeedbackEntity;
import io.renren.modules.appManagement.service.AppFeedbackService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.common.utils.R;


/**
 * 
 * 
 * @author zhubsh
 * @email sd_zhusbh@163.com
 * @date 2019-07-30 14:42:23
 */
@RestController
@RequestMapping("appManagement/appfeedback")
public class AppFeedbackController {
	@Autowired
	private AppFeedbackService appFeedbackService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("appManagement:appfeedback:list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);

		List<AppFeedbackEntity> appFeedbackList = appFeedbackService.queryList(query);
		int total = appFeedbackService.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(appFeedbackList, total, query.getLimit(), query.getCurrPage());
		
		return R.ok().put("page", pageUtil);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{id}")
	@RequiresPermissions("appManagement:appfeedback:info")
	public R info(@PathVariable("id") Long id){
		AppFeedbackEntity appFeedback = appFeedbackService.queryObject(id);
		
		return R.ok().put("appFeedback", appFeedback);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("appManagement:appfeedback:save")
	public R save(@RequestBody AppFeedbackEntity appFeedback){
		appFeedbackService.save(appFeedback);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("appManagement:appfeedback:update")
	public R update(@RequestBody AppFeedbackEntity appFeedback){
		appFeedbackService.update(appFeedback);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("appManagement:appfeedback:delete")
	public R delete(@RequestBody Long[] ids){
		appFeedbackService.deleteBatch(ids);
		
		return R.ok();
	}
	
}
